﻿
using _05原型设计模式;

Console.WriteLine("原型设计模式");
Student student=new Student("mhg");
Student student1=(Student)student.Clone();
Console.WriteLine(student.GetHashCode());
Console.WriteLine(student1.GetHashCode());
Console.WriteLine(student1.Name);

Console.WriteLine("C#自己继承ICloneable");
Teacher teacher=new Teacher("mhg2");
Teacher teacher2=(Teacher)teacher.Clone();

Console.WriteLine(teacher.GetHashCode());
Console.WriteLine(teacher2.GetHashCode());
Console.WriteLine(teacher2.Name);

Console.WriteLine("原型伪君深拷贝");

Resume resume =new Resume();
resume.SetInfo("孙权", 30, '男');
resume.SetWorkExperience("2018-2022", "鹅厂");
Resume resume2 =  (Resume)resume.Clone();
Resume resume3 = (Resume)resume.Clone();
Resume resume4 = (Resume)resume.Clone();
resume2.SetWorkExperience("2008-2010", "华为");
resume3.SetWorkExperience("2010-2018", "阿里");
resume4.SetWorkExperience("2010-2024", "B站");
resume.ShowResume();
resume2.ShowResume();
resume3.ShowResume();
resume4.ShowResume();
// 严格意义上的深拷贝要利用反射和序列化
//  浅拷贝对值类型 搞一个新的，引用类型：搞一个引用
// 深拷贝  值类型和引用类型都会搞一个新的